<template>
  <div class="app-container">
    <!-- 上部分表单 -->
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="68px"
      label-position="left"
      class="globalSerchFormStyle"
      style="margin: 10px 0px"
    >
      <el-row>
        <el-col :span="6">
          <el-form-item label="油企" prop="orderNo">
            <el-input
              v-model="queryParams.orderNo"
              placeholder="请输入订单号"
              clearable
              @keyup.enter.native="handleQuery"
              style="width: 190px"
              size="small"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="油站" prop="likeConsumer">
            <el-input
              v-model="queryParams.likeConsumer"
              placeholder="请输入客户姓名"
              clearable
              @keyup.enter.native="handleQuery"
              style="width: 190px"
              size="small"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="班结时间" prop="createdDate">
            <el-date-picker
              size="small"
              style="width: 190px"
              v-model="dateRangeCreatedDate"
              value-format="yyyy-MM-dd HH:mm:ss"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>

      <div class="button-from">
        <!--<el-form-item label="油品名称" prop="oilName">
          <el-select
            v-model="queryParams.oilName"
            placeholder="油品名称"
            clearable
            style="width: 350px"
            size="small"
          >
            <el-option
              v-for="dict in oilNameOptions"
              :key="dict.dictLabel"
              :label="dict.dictLabel"
              :value="dict.dictLabel"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="加油员" prop="oilPersonnel">
          <el-input
            v-model="queryParams.oilPersonnel"
            placeholder="请输入加油员"
            clearable
            style="width: 350px"
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>-->

        <!-- <el-form-item label="" prop="oilGun">
          <el-input
            v-model="queryParams.oilGun"
            style="width: 250px"
            size="small"
            placeholder="请输入油枪"
            clearable
            @keyup.enter.native="handleQuery"
          />
        
        </el-form-item>-->
      </div>
    </el-form>

    <el-row class="global_el_rowStyle" :gutter="10">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-search"
          @click="handleQuery"
          size="mini"
          >搜索</el-button
        >
      </el-col>
    </el-row>

    <!-- 表格 -->
    <!-- <div class="card-table"> -->
    <!--
      <el-button icon="el-icon-message" size="small" type="success">新增</el-button>
      <el-button icon="el-icon-message" size="small">导出</el-button>
      <el-button icon="el-icon-message" size="small">打印</el-button>
      -->
    <el-table style="width: 100%" :data="orderList" stripe>
      <af-table-column label="序号" align="left" prop="orderNo" />
      <af-table-column label="时间" align="left" prop="oilPirce" />
      <af-table-column
        label="油机加油金额（元）"
        align="left"
        prop="receivableAmt"
      />
      <af-table-column label="订单数" align="left" prop="discountAmt" />
      <af-table-column label="油站" align="left" prop="consumer" />
      <af-table-column label="修改人" align="left" prop="oilPersonnel" />
      <af-table-column label="修改时间" align="left" prop="oilGun" />
      <af-table-column
        label="操作"
        align="left"
        class-name="small-padding fixed-width"
        width="400px"
      >
        <!--fixed="right"-->
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="
              goNewPage('/overview/Overview_WorkOutReport_See', scope.row)
            "
            >查看详情</el-button
          >
          <el-button
            size="mini"
            type="text"
            @click="
              goNewPage('/overview/Overview_WorkOutReport_Delivery', scope.row)
            "
            >付油日报表</el-button
          >
          <el-button
            size="mini"
            type="text"
            @click="
              goNewPage('/overview/Overview_WorkOutReport_Change', scope.row)
            "
            >跳变日报表</el-button
          >
        </template>
      </af-table-column>
    </el-table>
    <!-- </div> -->
    <!-- 分页 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<script>
import { listOrder, exportOrder, printOrderInfo } from "@/api/station/order";
import { getSettlement} from "@/api/settlement";
import { stationinfo } from "@/api/station/gun";
import { listPrice, getPrice } from "@/api/station/price";
import { listManage } from "@/api/station/manage";

export default {
  name: "Order_Oil",
  data() {
    return {
      //创建订单时间间隔
      dateRangeCreatedDate: [],
      // 总条数
      total: 0,
      // 订单支付表格数据
      orderList: [],
      oilNameOptions: [],
      // 字典
      payTypeOptions: [],
      // 下拉油站
      stationOptions: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        levelId: this.levelId,
        pageNum: 1,
        pageSize: 10,
        oilGun: null,
        oilName: null,
        stationId: null,
        orderType: null,
        //orderType:1,
        oilPersonnel: null,
        createdDate: null,
        likeConsumer: null,
        orderNo: null,
      },
      // 表单校验
      rules: {},
      reprint: false,
    };
  },
  created() {
    this.getList();
    listManage({
      pageNum: 1,
      pageSize: 1,
    }).then((response) => {
      const equipmentList = response.rows;
      if (!!equipmentList) {
        if ((equipmentList[0] || {}).deviceType == "1") {
          this.reprint = true;
        }
      }
    });
    //字典
    this.getDicts("pay_type").then((response) => {
      this.payTypeOptions = response.data;
    });
    stationinfo().then((response) => {
      this.stationOptions = response.rows;
    });
    this.getDicts("oil_name").then((response) => {
      this.oilNameOptions = response.data;
    });
  },
  methods: {
    goNewPage(url, row) {
      this.$router.push({
        path: url,
        query: { stationId: 1 },
      });
    },
    payTypeFotmat(row, column) {
      if (row.payType === "wx") {
        return "微信支付";
      } else if (row.payType === "zfb") {
        return "支付宝";
      } else if (row.payType === "xj") {
        return "现金支付";
      } else if (row.payType === "dzk") {
        return "电子卡支付";
      } else if (row.payType === "POS") {
        return "POS机支付";
      } else if (row.payType === "yzf") {
        return "预支付";
      } else if (row.payType === "kbzf") {
        return "卡包支付";
      }
    },
    statusFotmat(row, column) {
      if (row.status === "0") {
        return "未支付";
      } else if (row.status === "1") {
        return "已支付";
      } else if (row.status === "2") {
        return "线下退款";
      } else if (row.status === "3") {
        return "线上退款";
      }
    },
    /** 查询订单支付列表 */
    getList() {
      getSettlement({}).then((response) => {
        this.orderList = response.rows;
        this.total = response.total;
        console.log("orderList", this.orderList);
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreatedDate = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //打印订单小票
    printOrderInfo(row) {
      // printOrderInfo({ orderId: row.orderId }).then((response) => {
      //   this.msgSuccess("小票打印成功");
      // });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有订单支付数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportOrder(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
        });
    },
  },
};
</script>
<style lang="scss" scoped>
.app-container {
  margin-top: -15px;
}

.button-from {
  width: 100%;
  display: flex;
  flex-wrap: wrap;

  .button-style1 {
    display: inline-block;
    width: 80px;

    .el-button {
      margin: 0 0 0 15px;
    }
  }
}

::v-deep .card-table {
  padding: 10px;
  margin-top: 20px;
  background-color: #f8f8f8;

  .el-button {
    margin: 0 5px 0 0;
  }
}

// 表格样式
::v-deep .el-form-item {
  margin-bottom: 0;

  .el-form-item__label {
    padding: 0;
    margin: 0;
    height: 29px;
    font-weight: 400;
    font-size: 12px;
  }

  .el-button--cyan {
    margin-left: 20px;
  }
}

::v-deep .el-table {
  border: 1px #f8f8f8 solid;
  border-bottom: 1px #dfe6ec solid;
}

::v-deep .is-center {
  border: 1px transparent solid;
  border-bottom: 1px #f8f8f8 solid;
}
</style>
